<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="waeather, forecast, australia weather, school temparature, school weather" />
<meta name="description" content="Townsville Weather Simulation" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Townsville Weather Simulation</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />


<!-- 

Google Analytics code implemtion block, The ID below should match with Google analytics registartion. Updating below code block before end of </head> tag

  _gaq.push(['_setAccount', 'UA-19282567-1']);


-->

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19282567-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

</head>
<body>
	<div id="header">
		<div id="logo">
            <img src="images/weather.jpg" width=900px height=150px border=0 />
		</div>
	</div>
	<!-- end #header -->
	<div id="menu">
		
		<ul>			
			<li><a href="index.php">Townsville Weather</a></li>
			<li><a href="wnews.php">Weather News</a></li>
			<li><a href="videos.php">Knowledge Repository</a></li>
			<li><a href="aboutus.php">Abous Us</a></li>
            <li><a href="feedback.php">Feedback</a></li>
			<li><a href="contactus.php">Contact Us</a></li>
		</ul>
		
	</div>
	<!-- end #menu -->


<div id="wrapper">
<div class="btm">
	<div id="page">
		<div id="content">
							
		<div class="post">
			<div class="entry">
				<h1 class="title"><a href="#">Current Conditions: </a></h1><br><br>
		<p>
					<TABLE CELLPADDING=5 CELLSPACING=0 border=1 align=center>
					<TR BGCOLOR=GRAY>
					<TH>SCHOOL NAME</TH>
					<TH>DATE AND TIME</TH>
					<TH>TEMPARATURE</TH>
					<TH>WIND SPEED</TH>
					<TH>WIND DIRECTION</TH>					
					<TH>STATUS</TH>
					</TR>

					<TR>					
					<?php
						try
						{
						// Import database util script once to get the properties and getConnection() function
						require_once 'databaseUtil.php';
						$stConn = getConnection();
						$station_sql="select * from stations where stationid='$_GET[school_one]'";
						// Result set for query
						$station = mysql_query($station_sql,$stConn);

						// Fetch individual record 
						while($stationREC = mysql_fetch_array($station))
						  {
						   echo "<TD><FONT COLOR=BLUE SIZE=3>$stationREC[name]</FONT></TD>";
						   
						  }


					$weatherConn = getConnection();
					// Sort the record by time in descending order and use limit 0,1 - for pulling one record from top
					$weather_sql="select * from weather where stationid='$_GET[school_one]' ORDER BY reporteddate desc LIMIT 0,1";
					$waeatherValues = mysql_query($weather_sql,$weatherConn);

					while($weatherREC = mysql_fetch_array($waeatherValues))
						  {
						     					   
								// Convert text format date time to user presentable format
							    $oDate = strtotime($weatherREC['reporteddate']); 
								$sDate = date("d/m/Y h:i A",$oDate); 								
								echo "<TD>$sDate</TD>";
								echo "<TD>$weatherREC[temparature]<sup>o</sup> C </TD>";
								echo "<TD>$weatherREC[speed] mph </TD>";
								echo "<TD>$weatherREC[direction]</TD>";								
								echo "<TD>";
								if($weatherREC["temparature"]>20)
								 {
								 echo "<img src=sunny.png border=0 height=50 width=50></img>";
								 }else if($weatherREC["temparature"]>15)
								 {
								 echo "<img src=sunnycloudy.png border=0 height=50 width=50></img>";
								 }
								 else{
								 echo "<img src=rain.png border=0 height=50 width=50></img>";								
								 }					
						  }	

					echo "</TD></TR>";

					// For Second shool used in comparision

					echo "<TR>";

					$station_sql="select * from stations where stationid='$_GET[school_second]'";
						// Result set for query
						$station = mysql_query($station_sql,$stConn);

						// Fetch individual record 
						while($stationREC = mysql_fetch_array($station))
						  {
						   echo "<TD><FONT COLOR=BLUE SIZE=3>$stationREC[name]</FONT></TD>";
						   
						  }


					$weatherConn = getConnection();
					// Sort the record by time in descending order and use limit 0,1 - for pulling one record from top
					$weather_sql="select * from weather where stationid='$_GET[school_second]' ORDER BY reporteddate desc LIMIT 0,1";
					$waeatherValues = mysql_query($weather_sql,$weatherConn);

					while($weatherREC = mysql_fetch_array($waeatherValues))
						  {
						     					   
								// Convert text format date time to user presentable format
							    $oDate = strtotime($weatherREC['reporteddate']); 
								$sDate = date("d/m/Y h:i A",$oDate); 								
								echo "<TD>$sDate</TD>";
								echo "<TD>$weatherREC[temparature]<sup>o</sup> C </TD>";
								echo "<TD>$weatherREC[speed] mph </TD>";
								echo "<TD>$weatherREC[direction]</TD>";								
								echo "<TD>";
								if($weatherREC["temparature"]>20)
								 {
								 echo "<img src=sunny.png border=0 height=50 width=50></img>";
								 }else if($weatherREC["temparature"]>15)
								 {
								 echo "<img src=sunnycloudy.png border=0 height=50 width=50></img>";
								 }
								 else{
								 echo "<img src=rain.png border=0 height=50 width=50></img>";								
								 }							
						  }	

					echo "</TD></TR></TABLE>";  
					
					closeConnection($stConn);
					closeConnection($weatherConn);
						}catch(Exception $dbEX)
						{
						closeConnection($stConn);
						closeConnection($weatherConn);
						echo "<br><br>System error: Sorry, Unable to retrieve weather values from Database...<br>";
						}
					?>		


</b></p>
			</div></div>      
           
            
            
		</div>
		<!-- end #content -->
		
		<div style="clear: both;">&nbsp;</div>
	</div>
	<!-- end #page -->
</div>
</div>
	<div id="footer">
		<p>
        	<a href="index.php">Townsville Weather</a> |
			<a href="wnews.php">Weather News</a> |
			<a href="videos.php">Knowledge Repository</a> |
			<a href="aboutus.php">Abous Us</a> |
            <a href="feedback.php">Feedback</a> |
			<a href="contactus.php">Contact Us</a><br><br>
        Copyright (c) 2010 JCU - Townsville Weather Simulation Project. All rights reserved.</p>
	</div>
	<!-- end #footer -->
</body>
</html>
